package com.tjackson;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/4/16  19:00
 * 描述:
 */
public class TEstJackson {

    public static void main(String[] args) throws IOException {

        Map<String,Object> map=new HashMap<>();

        map.put("zhangsan","123456");

        Map<String,Object> map2=new HashMap<>();

        map2.put("lisi","45678");

        List<Map<String,Object>> list=new ArrayList<>();
        list.add(map);
        list.add(map2);

        Map<String,Object> map3=new HashMap<>();
        map3.put("array",list);


        String json=JSONObject.toJSONString(map3);

        ObjectMapper objectMapper=new ObjectMapper();

        JsonNode jsonNode = objectMapper.readTree(json);

        JsonNode array = jsonNode.withArray("array");

        for (JsonNode node : array) {
            System.out.println(node.toString());
        }

        System.out.println(array.isArray());

    }

}
